package Group9.TodoManager.Data.Interface;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;


/**
 * Create a base class for table model with a set of functionality
 * @author Rupesh
 */
public interface ITableModel<T>
{
	/**
     * Adds listener to the table model in case some property is changed
     * @param l the listener to be added
     */
    public void addPropertyChangeListener(PropertyChangeListener l);

    /**
     * Removes listener from the table model in case it is added before
     * @param l the listener to be removed
     */
    public void removePropertyChangeListener(PropertyChangeListener l);

    /**
     * Fire an event about change of property
     * All added listeners will be notified of the change of property by
     * this method
     * @param event event of property change
     */
    public void firePropertyChangedEvent(PropertyChangeEvent e);

    /**
     * Returns the selected index of the row in the table
     * @return
     */
    public int getSelectedRowIndex();

    /**
     * This is the setter method for selecting a row
     * @param selectedRowIndex
     */
    public void setSelectedRowIndex(int selectedRowIndex);

    /**
     * Adds a column to the table
     * @param columnName The columnname to add in the table.
     */
    public void addColumn(String columnName);

    /**
     * Adds the column with specified column name and display value.
     * @param columnDisplayName The column name that is to be displayed in the
     * header of the table in the view.
     * @param propertyName The property name that maps to the object.
     */
    public void addColumn(String columnDisplayName, String propertyName);

    /**
     * Adds the provided column list to the table in view. It consider the
     * column name and column display value to be same.
     * @param columnsList The list of columns to add in the table.
     */
    public void addColumns(String[] columnsList);

    /**
     * Adds the specified list of columns and display names in the table.
     * @param columnsDisplayList The list of column display names
     * @param propertyList The list of columns name
     */
    public void addColumns(String[] columnsDisplayList,String[] propertyList);

    /**
     * Returns the list of columns being shown in the table.
     * @return The list of columns shown in the table.
     */
    public Iterable<String> getColumns();

    /**
     * This adds a row in the table.
     * @param task The object that is to be added to the table.
     */
    public void addRow(T task);

    /**
     * This feeds the table with the list of objects provided.
     * @param taskList The list of objects to be added in the table rows.
     */
    public void setDataSource(Iterable<T> taskList);

    /**
     * Returns the object associated with the specified row index.
     * @param index The row index to get the object.
     * @return The row object being shown for the specified row index.
     */
    public T getRowObject(int index);

    /**
     * Setter method for the object at the specified row index
     * @param rowIndex the index of the row
     * @param object object to be set at the specified row index
     */
    public void setRowObject(int rowIndex, T object);

    /**
     * Returns the value at the specified row and column index.
     * @param rowIndex The rowindex to get the value
     * @param columnIndex The columnindex to get the value
     * @return The value at the specified cell
     */
    public Object getValueAt(int rowIndex, int columnIndex);

    /**
     * Returns the column at the specified index.
     * @param index the index of the column.
     * @return the column name at the specified index.
     */
    public String getColumnAt(int index);

    /**
     * Removes the specified row index object from the table.
     * @param index The row index for which the row is to be removed.
     */
    public void removeRowAt(int index);

    /**
     * It clears all the rows from the table.
     */
    public void clearRows();

}
